TakeWhile(TSource) Method (ParallelQuery(TSource), Func(TSource, Int32, Boolean))

Task Parallel System.Threading

Returns elements from a parallel sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.

Namespace:  System.Linq
Assembly:  System.Threading (in System.Threading.dll)

Syntax

Visual Basic (Declaration)
Public Shared Function TakeWhile(Of TSource) ( _
	source As ParallelQuery(Of TSource), _
	predicate As Func(Of TSource, Integer, Boolean) _
) As ParallelQuery(Of TSource)
C#
public static ParallelQuery<TSource> TakeWhile<TSource>(
	ParallelQuery<TSource> source,
	Func<TSource, int, bool> predicate
)

Parameters

source
Type: System.Linq..::.ParallelQuery<(Of <(TSource>)>)
The sequence to return elements from.
predicate
Type: System..::.Func<(Of <(TSource, Int32, Boolean>)>)
A function to test each source element for a condition; the second parameter of the function represents the index of the source element.

Type Parameters

TSource
The type of elements of source.

Return Value

A sequence that contains elements from the input sequence that occur before the element at which the test no longer passes.

Exceptions

ExceptionCondition
System..::.ArgumentNullException source or predicate is a null reference (Nothing in Visual Basic).

See Also